package com.bytecodezz.app.sketch.draw.ui

import android.os.Bundle
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.bytecodezz.app.sketch.common.base.BaseUIActivity
import com.bytecodezz.app.sketch.common.router.DrawPath
import com.bytecodezz.app.sketch.draw.databinding.DrawActivityDrawMainUiBinding
import com.bytecodezz.app.sketch.draw.model.DrawViewModel


@Route(path = DrawPath.ACTIVITY_DRAW_MAIN_VIEW)
class DrawMainUI : BaseUIActivity<DrawActivityDrawMainUiBinding, DrawViewModel>() {

    override fun onCreateViewBinding() = DrawActivityDrawMainUiBinding.inflate(layoutInflater)

    override fun onCreateViewModelClass() = DrawViewModel::class.java

    override fun initOtherObserver() {
        super.initOtherObserver()
        //初始化事件
        viewModel.actionViewIsHide.observe(this) { isGone ->
            if (isGone) {
                binding?.drawActionBarView?.visibility = View.GONE
            } else {
                binding?.drawActionBarView?.visibility = View.VISIBLE
            }
        }
    }

    override fun onActionPostView() {
        viewModel.initSystemActionBar(window.decorView)
        super.onActionPostView()
    }

    override fun onActionStart(savedInstanceState: Bundle?) {
        viewModel.initDrawStart()
    }

    fun onClickFullScreen(view: View) {
        view.isSelected = !view.isSelected
        viewModel.fullScreenActionAnimation(view.isSelected, binding?.drawActionBarView!!)
    }

    fun onClickActionMore(view: View) {
        view.isSelected = !view.isSelected
    }

    fun onClickActionLayer(view: View) {
        view.isSelected = !view.isSelected
    }

    fun onClickActionTools(view: View) {
        view.isSelected = !view.isSelected
    }
}